package cn.pku.ss.fa.ui.component;

import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import org.zkoss.zul.Div;
import cn.pku.ss.fa.bean.NewsBean;

/**
 * @author SirX
 */
public class NewsComponent extends Div {
	
	public NewsComponent() {
		this.initNewsList();
	}
	
	public List<NewsBean> getNews() {
		return this.newsList;
	}
	
	//////////////////////////////////////////////////////////////////////////////
	
	private void initNewsList() {
		//TODO: home page
		this.newsList = new LinkedList<NewsBean>();
		for(int i=0; i<33; i++) {
			Calendar calendar = Calendar.getInstance(Locale.US);
			String title = "News"+i+" title title title title";
			String content = "News"+i+" content: many words many words many words many words many words many words many words many words many words many words many words ";
			NewsBean bean = new NewsBean();
			bean.setDate(""+calendar.get(Calendar.YEAR)+"-"+calendar.get(Calendar.MONTH)+"-"+calendar.get(Calendar.DAY_OF_MONTH));
//			bean.setDate(""+calendar.get(Calendar.MONTH)+"/"+calendar.get(Calendar.DAY_OF_MONTH)+"/"+calendar.get(Calendar.YEAR)
//					+"\t"+calendar.get(Calendar.HOUR_OF_DAY)+":"+calendar.get(Calendar.MINUTE));
			bean.setTitle(title);
			bean.setContent(content);
			newsList.add(bean);
		}
	}
	
	//////////////////////////////////////////////////////////////////////////////

	private List<NewsBean> newsList;

}
